package com.cn.hotel.dao.Impl;

import com.cn.hotel.dao.IFacilitiesDao;
import com.cn.hotel.model.FacilitiesModel;
import com.cn.hotel.model.NavModel;
import com.cn.hotel.util.GetSqlSession;
import com.cn.hotel.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class FacilitiesImpl implements IFacilitiesDao {
    @Override
    public List<FacilitiesModel> findAll(FacilitiesModel facilitiesModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.IFacilitiesDao.findAll",facilitiesModel);
    }

    /**
     * 获取数据库总条数
     * @param facilitiesModel
     * @return
     */
    @Override
    public int getNumber(FacilitiesModel facilitiesModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.IFacilitiesDao.getNumber",facilitiesModel);
    }

    /**
     * 新增设施介绍
     * @param facilitiesModel
     * @return
     */
    @Override
    public int add(FacilitiesModel facilitiesModel) {
        return  GetSqlSession.getSqlSession().insert("com.cn.hotel.dao.IFacilitiesDao.add",facilitiesModel);
    }

    /**
     * 通过id查询信息 给页面赋值
     * @param temp
     * @return
     */
    @Override
    public FacilitiesModel findById(Integer temp) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.IFacilitiesDao.findById",temp);
    }

    /**
     * 保存编辑修改
     * @param facilitiesModel
     * @return
     */
    @Override
    public int edit(FacilitiesModel facilitiesModel) {
        return GetSqlSession.getSqlSession().update("com.cn.hotel.dao.IFacilitiesDao.edit",facilitiesModel);
    }

    @Override
    public int delete(Integer temp) {
       return GetSqlSession.getSqlSession().delete("com.cn.hotel.dao.IFacilitiesDao.delete",temp);
    }
//-------------------------前端数据获取代码----------------------------------------
    @Override
    public List<FacilitiesModel> getFacilitiesModel(Integer pageNumber) {
       return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.IFacilitiesDao.getFacilitiesModel",pageNumber);
    }

    @Override
    public List<FacilitiesModel> getDetails(Integer temp) {
        return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.IFacilitiesDao.getDetails",temp);
    }

    @Override
    public int getCount() {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.IFacilitiesDao.getCount");
    }
}
